let express = require('express')
let path = require('path')
let proxy = require('express-http-proxy')

let app = express()

// 当访问data开头的url的时候，代理到localhost:8000去
app.use('/admin', proxy('http://localhost:8081', {
  proxyReqPathResolver: function (req) {
  	return '/admin' + req.url
  }
}));

app.use(/\/.+\.gz$/, function(req, res, next) {
	res.set({
		"content-encoding": 'gzip',
		"Content-Type": "text/css"
	})
	next()
})
// 设置静态文件托管, 当用户的url以plblic开头，则返回对应__dirname + '/plblic'下的文件
app.use('/', express.static(path.join(__dirname, './dist')))
app.use('/dll', express.static(path.join(__dirname, './dll')))


app.listen(3008, function() {
	console.log('server is runing http://localhost:3008...')
})